import java.io.File;
import java.io.IOException;

import com.aliasi.chunk.CharLmHmmChunker;
import com.aliasi.chunk.Chunk;
import com.aliasi.chunk.Chunking;
import com.aliasi.corpus.parsers.Muc6ChunkParser;
import com.aliasi.hmm.HmmCharLmEstimator;
import com.aliasi.tokenizer.IndoEuropeanTokenizerFactory;
import com.aliasi.tokenizer.TokenizerFactory;


public class SolutionLingpipeHMM {
	static final int MAX_N_GRAM = 8;
	static final int NUM_CHARS = 256;
	static final double LM_INTERPOLATION = MAX_N_GRAM; // default behavior

	public static void main(String[] args) throws IOException {
	    File corpusFile = new File(args[0]);
	    String testingFile = "";

	    System.out.println("Setting up Chunker Estimator");
	    TokenizerFactory factory
	      = IndoEuropeanTokenizerFactory.INSTANCE;
	    HmmCharLmEstimator hmmEstimator
	      = new HmmCharLmEstimator(MAX_N_GRAM,NUM_CHARS,LM_INTERPOLATION);
	    CharLmHmmChunker chunkerEstimator
	      = new CharLmHmmChunker(factory,hmmEstimator);

	    System.out.println("Setting up Data Parser");
	    Muc6ChunkParser parser = new Muc6ChunkParser();
	    parser.setHandler(chunkerEstimator);

	    System.out.println("Training with Data from File=" + corpusFile);
	    parser.parse(corpusFile);

	    Chunking chunking = chunkerEstimator.chunk(testingFile);
		for (Chunk chunk : chunking.chunkSet()) {
			System.out.println(chunk);
        }
	}
}
